import axios from 'axios';
import {message } from 'antd';

//创建实例
const service = axios.create({
    baseURL: process.env.REACT_APP_API,
    timeout:10000,
})

//请求拦截
service.interceptors.request.use(function(config){
    return config

},function(error){

    return Promise.reject(error)
})

//响应拦截
service.interceptors.response.use(function(response){
    console.log(response)
    if(response.status === 200){
        if(response.data.resCode === 0){
            return response.data
        }else{
            message.error(response.data.message);
        }
    }
},function(error){
 
    return Promise.reject(error)
})
 
export default service;